// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import iView from 'iview'
import 'iview/dist/styles/iview.css';
import axios from 'axios';
import htmlToPdf from './js/htmlToPdf';

//axios拦截器
axios.interceptors.request.use(
  (config) => {
    // console.log('config', config);
    if (window.localStorage.getItem('screeningLogin')) {
      config.headers.token = window.localStorage.getItem('screeningLogin')
    }
    return config;
  },
  (err) => {
    return Promise.reject(err);
  }
)

axios.interceptors.response.use(
  (response) => {
    console.log('axios response', response.data.status);
    if (response.data.status == '403') {
      // this.$Notice.warning({desc: '请重新登陆'})
      window.localStorage.removeItem('screeningLogin');
      router.replace({
        path: '/login2',
        query: {redirect: router.currentRoute.fullPath}
      })
    }
    return response;
  },
  (err) => {
    console.log(err);
  }
)

Vue.config.productionTip = false
Vue.use(iView)
Vue.use(htmlToPdf)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: {App},
  template: '<App/>'
})
